#ifndef HIGHLIGHT_H
#define HIGHLIGHT_H
#include "qsyntaxhighlighter.h"
#include <QRegularExpression>
typedef QRegularExpression Qregex;

struct Rule{
    QRegularExpression pattern;
    QTextCharFormat* format;
public:
    Rule(Qregex pat,QTextCharFormat *fmt){
        pattern = pat;
        format = fmt;
    }
    Rule(){}
};
QString converRGB16HexStr(QColor _color);

extern QTextCharFormat labelFormat;
extern QTextCharFormat Title1Format;
extern QTextCharFormat Title2Format;
extern QTextCharFormat Title3Format;
extern QTextCharFormat Title4Format;
extern QTextCharFormat Title5Format;
extern QTextCharFormat Title6Format;
extern QTextCharFormat QuoteFormat;
extern QTextCharFormat ListFormat;
extern QTextCharFormat OlistFormat;
extern QTextCharFormat LinkFormat;
extern QTextCharFormat emFormat,strongFormat;
extern QTextCharFormat imgFormat;
extern QTextCharFormat codeFormat;
extern QTextCharFormat delFormat;
extern QTextCharFormat tabelFormat;

extern Rule table;
extern Rule Title1;
extern Rule Title2;
extern Rule Title3;
extern Rule Title4;
extern Rule Title5;
extern Rule Title6;
extern Rule Quote;
extern Rule List;
extern Rule Olist;
extern Rule Link;
extern Rule em;
extern Rule strong;
extern Rule img;
extern Rule code;
extern Rule del;
extern Rule label;

class highlight:public QSyntaxHighlighter
{
public:
    void init(double size);
    void writeDocu();
    explicit highlight(double size,QTextDocument* father = nullptr);
    void highlightBlock(const QString &text) override;
private:
    double size;
    QVector<Rule> highRules = {table,Title1,Title2,Title3,Title4,Title5,Title6,Quote,List,Olist,Link,em,strong,img,code,del,label};
};

#endif // HIGHLIGHT_H
